home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DMAKE38B.ARJ / _CHDIR.C < prev    next >
C/C++ Source or Header  |  1992-01-23  |  2KB  |  68 lines

  1. /* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/msdos/_chdir.c,v 1.1 1992/01/24 03:27:24 dvadura Exp $
  2. -- SYNOPSIS -- Change directory.
  3. -- 
  4. -- DESCRIPTION
  5. --    Under DOS change the current drive as well as the current directory.
  6. --
  7. -- AUTHOR
  8. --      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  9. --      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  10. --
  11. -- COPYRIGHT
  12. --      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  13. -- 
  14. --      This program is free software; you can redistribute it and/or
  15. --      modify it under the terms of the GNU General Public License
  16. --      (version 1), as published by the Free Software Foundation, and
  17. --      found in the file 'LICENSE' included with this distribution.
  18. -- 
  19. --      This program is distributed in the hope that it will be useful,
  20. --      but WITHOUT ANY WARRANTY; without even the implied warrant of
  21. --      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22. --      GNU General Public License for more details.
  23. -- 
  24. --      You should have received a copy of the GNU General Public License
  25. --      along with this program;  if not, write to the Free Software
  26. --      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27. --
  28. -- LOG
  29. --     $Log: _chdir.c,v $
  30.  * Revision 1.1  1992/01/24  03:27:24  dvadura
  31.  * dmake Version 3.8, Initial revision
  32.  *
  33. */
  34.  
  35. #include <dos.h>
  36. #include "extern.h"
  37.  
  38. PUBLIC int
  39. _chdir(path)
  40. char *path;
  41. {
  42.    int   res;
  43.  
  44.    res = chdir(path);
  45.  
  46. #if defined(OS2)
  47.    if (res != -1 && path[1] == ':') {
  48.       unsigned new_drive;
  49.       unsigned max_drives;
  50.  
  51.       /* for OS2 we must change drive without using intdos() */
  52.       new_drive = (*path & ~0x20) - 'A' + 1;
  53.       _dos_setdrive(new_drive, &max_drives);
  54.    }
  55. #else
  56.    if (res != -1 && path[1] == ':') {
  57.       union REGS  reg;
  58.  
  59.       /* we must change the logged drive, since the chdir worked. */
  60.       reg.h.ah = 0x0E;
  61.       reg.h.dl = (*path & ~0x20) - 'A';
  62.       intdos(®, ®);
  63.    }
  64. #endif /* OS2 */
  65.    return (res);
  66. }
  67.  
  68.